****REPLICATION DATA FOR "HOW DID TUNISIANS REACT TO ENNAHDHA'S 2016 REFORMS? EVIDENCE FROM A SURVEY EXPERIMENT"****
****PLEASE SEE ASSOCIATED .R FILE FOR CODE REPLICATING FIGURES IN PAPER AND APPENDIX****
#delimit;
clear;
use medpol_replication_nahdha.dta;
***Figure 1 Underlying models: Favorability by Secularism and Education***
tab Q8_recode,sum(Q23_recode);
tab Q3,sum(Q23_recode);

***Table 2: Examining Favorability of Institutionalization***
#delimit;
oprobit Q23_recode r2 GENDER Q1 Q2 unemployed Q3 rural Q6_recode Q8_recode Q9_recode Q13 Q19 nahda nidaa partys  [iw=weight], vce(cluster BID);
eststo d1;
oprobit Q23_recode r2 GENDER Q1 Q3 rural Q6_recode Q8_recode Q9_recode Q13 Q19 nahda nidaa partys  [iw=weight], vce(cluster BID);
eststo d3;
oprobit Q23_recode Q3 Q6_recode Q8_recode [iw=weight], vce(cluster BID);
eststo d4;
estout d4 d3 d1 using Q23_recode.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 


***Table 3: Examining Response to Ennahdha Reforms ****
#delimit;
xi: oprobit Q25_recode r2 r3 [iw=weight], vce(cluster BID) ;
eststo b1;
xi: oprobit Q25_recode i.r3*r2 [iw=weight], vce(cluster BID) ;
eststo b2;
estout b1 b2 using basic.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 

***Underlying Modes for Figure 2***

**T-tests of significant factors***
#delimit;
ttest Q25_recode if Q3==1, by(r3);
ttest Q25_recode if Q3==2, by(r3);
ttest Q25_recode if Q3==3, by(r3);
ttest Q25_recode if Q3==4, by(r3);
ttest Q25_recode if Q3==5, by(r3);

ttest Q25_recode if  rural==1, by(r3);
ttest Q25_recode if  rural==0, by(r3);

ttest Q25_recode if Q8_recode==1, by(r3);
ttest Q25_recode if Q8_recode==2, by(r3);
ttest Q25_recode if Q8_recode==3, by(r3);
ttest Q25_recode if Q8_recode==4, by(r3);
ttest Q25_recode if Q8_recode==5, by(r3);

ttest Q25_recode if Q13==1, by(r3);
ttest Q25_recode if Q13==2, by(r3);
ttest Q25_recode if Q13==3, by(r3);
ttest Q25_recode if Q13==4, by(r3);
ttest Q25_recode if Q13==5, by(r3);

ttest Q25_recode if  nahda==1, by(r3);
ttest Q25_recode if  nidaa==1, by(r3)
ttest Q25_recode if partysupport==1 & nahda!=1 & nidaa!=1, by(r3);
ttest Q25_recode if partysupport==0, by(r3);

***Disaggregating Secularism and Education***

#delimit;
gen education_noformal = 0;
gen education_elementary = 0;
gen education_highschool = 0;
gen education_university = 0;
gen education_higher = 0;
replace education_noformal=1 if Q3==1;
replace education_elementary=1 if Q3==2;
replace education_highschool =1 if Q3==3;
replace education_university =1 if Q3==4;
replace education_higher=1 if Q3==5;
replace education_noformal=. if Q3==.;
replace education_elementary=. if Q3==.;
replace education_highschool =. if Q3==.;
replace education_university =. if Q3==.;
replace education_higher =. if Q3==.;

#delimit
gen secularism_strongagree = 0;
gen secularism_agree= 0;
gen secularism_niether = 0;
gen secularism_disagree = 0;
gen secularism_strongdisagree= 0;
replace secularism_strongagree=1 if Q8==1;
replace secularism_agree=1 if Q8==2;
replace secularism_niether =1 if Q8==3;
replace secularism_disagree =1 if Q8==4;
replace secularism_strongdisagree=1 if Q8==5;
replace secularism_strongagree=. if Q8==.;
replace secularism_agree=. if Q8==.;
replace secularism_niether =. if Q8==.;
replace secularism_disagree =. if Q8==.;
replace secularism_strongdisagree=. if Q8==.;

***Table 3: Balance Tests***
#delimit;
svy: logit r1_binary GENDER Q1  Q2 Q3 unemployed Q6_recode Q8_recode Q9_recode rural Q19 region_ce region_cw region_nw region_so ;
eststo bal1;
svy: logit r2 GENDER Q1  Q2 Q3 unemployed Q6_recode Q8_recode Q9_recode rural Q19 region_ce region_cw region_nw region_so ;
eststo bal2;
svy: logit r3 GENDER Q1  Q2 Q3 unemployed Q6_recode Q8_recode Q9_recode rural Q19 region_ce region_cw region_nw region_so ;
eststo bal3;
estout bal1 bal2 bal3 using balance_nahdha.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 



***Table 4: Examining Heterogeneous Treatment Effects in Response to Ennahdha Reforms ***


#delimit;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree [iw=weight],vce(cluster BID) ;
eststo c1;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree i.r3*rural  i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys  [iw=weight],vce(cluster BID) ;
eststo c2;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree i.r3*rural i.r3*Q6_recode  i.r3*Q9_recode  i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID);
eststo c3;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree i.r3*rural i.r3*unemployed i.r3*Q6_recode  i.r3*Q9_recode i.r3*Q13 i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID) ;
eststo c4;
estout c1 c2 c3 c4 using heterogeneous_max.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 

****Underlying models for Figure 3****
#delimit;
xi: oprobit Q25_recode i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher [iw=weight],vce(cluster BID) ;
vce;
xi: oprobit Q25_recode i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree [iw=weight],vce(cluster BID) ;
vce;




*****APPENDIX*****

 
****Table 2: Comparing Demographics across surveys****
#delimit;
use medpol_replication_nahdha;
sum Q1  Q2 Q3  unemployed_parttime D8 GENDER;
use tun7ab;
recode Q97 (13=.);
replace Q1=Q1+16;
gen unemployed_parttime=0;
replace unemployed=1 if Q94==4 | Q94==3;
sum Q1 Q101 Q97 unemployed URBRUR;
clear;
use abtun4;
recode t1003 (8=.);
sum q1001 q1002 t1003 q13;
tab q1004;
tab q1005;
tab q1006;

clear;


***Table 4: Demographics of Ennahdha and non-Ennahdha voters***

#delimit;
use medpol_replication_nahdha;
ttest GENDER, by(nahda); 
ttest Q1, by(nahda);
ttest Q2, by(nahda);
ttest Q3, by(nahda);
ttest unempl, by(nahda);
ttest Q6_recode, by(nahda);
ttest Q8_recode, by(nahda);
ttest Q9_recode, by(nahda);
ttest Q13, by(nahda);
ttest Q19, by(nahda);
ttest rural, by(nahda);


***Table 5: Support for Ennahdha***

#delimit;
logit nahda GENDER Q1 Q2 Q3 unemployed rural Q6_recode Q8_recode Q9_recode Q13 Q19 [pw=weight], vce(cluster BID);
eststo a1;
logit nahda GENDER Q1 Q3 rural  Q6_recode Q8_recode Q9_recode Q13 Q19  [pw=weight], vce(cluster BID);
eststo a2;
oprobit Q25_recode r2 GENDER Q1 Q2 Q3 unemployed rural  Q6_recode Q8_recode Q9_recode Q13 Q19 if r3!=1 [iw=weight], vce(cluster BID);
eststo a3;
oprobit Q25_recode r2 GENDER Q1 Q3 rural  Q6_recode Q8_recode Q9_recode Q13 Q19 if r3!=1 [iw=weight], vce(cluster BID);
eststo a4;
estout a2 a1 a4 a3 using descriptive.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 

clear;
***Table 5 Model AB IV: Predicting Support for Ennahdha***
use tun7ab;
gen nahda_support=0;
replace nahda_support=1 if Q88B==2;
gen nahda_vote=0;
replace nahda_vote=1 if Q99==3;
gen nahda_agg=0;
replace nahda_agg=1 if nahda_vote==1 | nahda_support==1;
logit nahda_agg Q1 Q101 Q97 unemployed  URBRUR;
clear;
use abtun4;
gen nahda_support=.;
replace nahda_support=1 if q503==21013;
replace nahda_support=0  if q503!=21013 & q503!=99998 & q503!=99999;
gen unemployed_parttime=0;
replace unemployed_parttime=1 if q1005==5 | q1006==2;
recode q6101 (1=5) (2=4) (4=2) (5=1) (6=.) (7=.);
recode t1003 (8=.);
recode q1015atun (3=.) (4=.);
recode q708 (1=4) (2=3) (3=2) (4=1) (5=.) (6=.);
recode q7114 (1=4) (2=3) (3=2) (4=1) (5=.) (6=.);
logit nahda_support q1001 q1002 t1003 q1015atun q13 unemployed_parttime q6101 q708 q7114;



***Table 6: Using original measure instead of disaggregated***

#delimit;
clear;
use medpol_replication_nahdha;
xi: oprobit Q25_recode i.r3*r2 i.r3*Q3 i.r3*Q8_recode [iw=weight],vce(cluster BID) ;
eststo c1;
xi: oprobit Q25_recode i.r3*r2 i.r3*Q3 i.r3*rural i.r3*Q8_recode i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys  [iw=weight],vce(cluster BID) ;
eststo c2;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q3 i.r3*rural i.r3*Q6_recode i.r3*Q8_recode i.r3*Q9_recode  i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID);
eststo c3;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q2 i.r3*Q3 i.r3*rural i.r3*unemployed i.r3*Q6_recode i.r3*Q8_recode i.r3*Q9_recode i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID) ;
eststo c4;
estout c1 c2 c3 c4 using heterogeneous_five.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 

****Table 7: Using Binary measures of Education and Secularism*****
#delimit;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_bin i.r3*secular_bin [iw=weight],vce(cluster BID) ;
eststo c1;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_bin  i.r3*rural i.r3*secular_bin i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys  [iw=weight],vce(cluster BID) ;
eststo c2;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*education_bin i.r3*rural i.r3*Q6_recode i.r3*secular_bin i.r3*Q9_recode  i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID);
eststo c3;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q2 i.r3*education_bin i.r3*rural i.r3*unemployed i.r3*Q6_recode i.r3*secular_bin i.r3*Q9_recode i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID) ;
eststo c4;
estout c1 c2 c3 c4 using heterogeneous_bin.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 


****Table 8: Predicting Attrition in DV***
#delimit;
gen Q25_recode_a=0;
replace Q25_recode_a=1 if Q25_recode==.;
logit Q25_recode_a r2 r3 r2r3 GENDER Q1 Q3 rural Q19 partys  [pw=weight], vce(cluster BID);
eststo att1;
logit Q25_recode_a r2 r3 r2r3 GENDER Q1 Q2 Q3 unemployed rural Q6_recode Q8_recode Q9_recode Q13 Q19 partys  [pw=weight], vce(cluster BID);
eststo att2;
logit Q25_recode_a r2 r3 r2r3 GENDER Q1 Q3 rural Q6_recode Q8_recode Q9_recode Q13 Q19 partys  [pw=weight], vce(cluster BID);
eststo att3;
estout att1 att3 att2 using Q25_recode_attrition.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex);

****Table 9: Horowitz and Manski (1998) technique for missingness***
**Imputing data***
mi set wide;
mi register imputed Q25_recode;
mi impute pmm Q25_recode r2 r3 r2r3 GENDER Q1 Q3 rural Q19 nahda nidaa partys, replace knn(5) add(50) force;
egen Q25_recode_imputed=rmean(_1_Q25_recode - _50_Q25_recode);
replace Q25_recode_imputed = round(Q25_recode_imputed,1);
recode Q25_recode_imputed (1=5) (2=4) (4=2) (5=1) if Q25_recode_attrition==1;
***Table for testing using imputed data***
#delimit;
xi: oprobit Q25_recode_imputed i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher  i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree   [iw=weight],vce(cluster BID) ;
eststo c1;
xi: oprobit Q25_recode_imputed i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher  i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree i.r3*rural i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys  [iw=weight],vce(cluster BID) ;
eststo c2;
xi: oprobit Q25_recode_imputed i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree  i.r3*rural i.r3*Q6_recode  i.r3*Q9_recode  i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID);
eststo c3;
xi: oprobit Q25_recode_imputed i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher  i.r3*rural i.r3*unemployed i.r3*Q6_recode i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree  i.r3*Q9_recode i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys [iw=weight], vce(cluster BID) ;
eststo c4;
estout c1 c2 c3 c4 using hm_test_max.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 




****Table 11: Using List Experiment as IV***
gen q21_listonly = q21_full*r1_binary;

#delimit;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree  i.r3*rural i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys i.r3*r1_binary i.r3*q21_full i.r3*q21_listonly [iw=weight],vce(cluster BID) ;
eststo c1;
xi: oprobit Q25_recode i.r3*r2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree  i.r3*rural i.r3*Q13 i.r3*nahda i.r3*nidaa i.r3*partys i.r3*r1_binary i.r3*q21_full i.r3*q21_listonly [iw=weight],vce(cluster BID) ;
eststo c2;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree   i.r3*rural i.r3*Q6_recode  i.r3*Q9_recode  i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys i.r3*r1_binary i.r3*q21_full i.r3*q21_listonly [iw=weight], vce(cluster BID);
eststo c3;
xi: oprobit Q25_recode i.r3*r2 i.r3*GENDER i.r3*Q1 i.r3*Q2 i.r3*education_noformal i.r3*education_elementary i.r3*education_uni i.r3*education_higher i.r3*secularism_agree i.r3*secularism_niether i.r3*secularism_disagree i.r3*secularism_strongdisagree   i.r3*rural i.r3*unemployed i.r3*Q6_recode i.r3*Q9_recode i.r3*Q10 i.r3*Q11 i.r3*Q12 i.r3*Q13  i.r3*Q19 i.r3*nahda i.r3*nidaa i.r3*partys i.r3*r1_binary i.r3*q21_full i.r3*q21_listonly [iw=weight], vce(cluster BID) ;
eststo c4;
estout c1 c2 c3 c4 using listq21_max.tex, replace cells(b(star fmt(%9.3f)) se(par)) stats(r2_a N, fmt(%9.3f %9.0g) labels(R-squared)) legend label collabels(none) varlabels(_cons \_cons) style(tex); 
 


**Mentioned: Cross Tabs of Favorability across secularism and education***
#delimit;
tab Q3,sum(Q23_recode);
tab Q8_recode, sum(Q23_recode);
